package main
import (
	"gopkg.in/gomail.v2"
	"log"
	"strconv"
)
func SendMail(config Config, subject string,body string)  {

	mail:=config.Mail
	passWord:=config.MailPassword
	portString:=config.Port

	m:=gomail.NewMessage()
	m.SetHeader("From",m.FormatAddress(mail,"打卡通知"))
	m.SetHeader("To",mail)
	m.SetHeader("Subject",subject)
	m.SetBody("text/html",body)
	port,_:=strconv.Atoi(portString)
	d:=gomail.NewDialer(config.Host,port,mail,passWord)
	err:=d.DialAndSend(m)
	if err!=nil{
		log.Printf("SendMail err #%v",err)
	}
}
